package com.wsjj.yjh.demo;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisCommands;

public class LettuceDemo {
    public static void main(String[] args) {
//        1.使用构造者方式创建URI
        RedisURI redis = RedisURI.builder().redis("hadoop102").withPort(6379).build();
//        2.创建连接客户端
        RedisClient redisClient = RedisClient.create(redis);
        StatefulRedisConnection conn = redisClient.connect();
//        3.获取操作对象
        RedisCommands sync = conn.sync();
//        4.写具体逻辑
        System.out.println(sync.ping());
        System.out.println(sync.keys("*"));
        System.out.println(sync.get("k1"));

//        5.关闭连接
        conn.close();
        redisClient.shutdown();
    }
}
